import java.util.Arrays;

public class nm {
    //冒泡排序的练习；
    public static void bobbleSort(int[] array){
        for(int i=0;i< array.length-1;i++){
            boolean flg=false;
            for(int j=0;j< array.length-1-i;j++){
                if(array[j]>array[j+1]) {
                    swap(array, j, j + 1);
                    flg=true;
                }
            }
            if(!flg){
                break;
            }
        }
    }
    public static void swap(int[] array,int i,int j){
        int tmp=array[i];
        array[i]=array[j];
        array[j]=tmp;
    }
public static void main(String[] args){
        int[] array={1,3,4,12,44,2,33};
        bobbleSort(array);
        System.out.println(Arrays.toString(array));
}
}
